package com.project.controller;

import com.project.bean.UserBean1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间)
 */
@Controller
@RequestMapping("test")//别名自己取
//类名记着自己改一下
public class TestControllerOne {

    @RequestMapping("checkName")
    public void checkName(String name,HttpServletResponse response) throws IOException {
        if ("java".equals(name)){
            response.getWriter().print("NO");
        }else {
            response.getWriter().print("YES");
        }
    }

    @RequestMapping("getString")
//    @ResponseBody//将方法返回的字符串作为字符串打印到网页上
    public String getString(){
        System.out.println("访问到了");
        return "/html/add.html";
    }

    @RequestMapping("getUser")
    @ResponseBody
    public UserBean1 getUser(HttpServletResponse response){
        return  new UserBean1(1,"浏览", LocalDate.parse("1998-07-22"));
    }

    @RequestMapping("getX")
    @ResponseBody
    public String getX(){
        return "3";
    }

}